def user():
    pwd = input('请输入密码：')
    if len(pwd)>=6:
        return pwd
    #创建一个异常对象
    ex = Exception('密码长度不够')
    raise ex
try:
    upwd = user()   #函数的返回值会返回到函数的调用处
    print(upwd)
except Exception as e:
    print('错误:%s'%e)